﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data.Linq.Mapping;

namespace Common
{
    [Table]
    public class DanhMucHangHoa
    {
        [Column(IsPrimaryKey=true, IsDbGenerated=true, DbType="Int NOT NULL IDENTITY", AutoSync = AutoSync.OnInsert)]
        public int iDanhMucHangHoa_ID { get; set; }
        [Column]
        public int iLoaiHangHoa_ID { get; set; }
        [Column]
        public string sMaHangHoa { get; set; }
        [Column]
        public string sTenHangHoa { get; set; }
        [Column]
        public int iDonViTinh_ID { get; set; }
        [Column]
        public decimal dGiaBan { get; set; }
        [Column]
        public decimal dGiaKhuyenMai { get; set; }
        [Column]
        public string sHinhDaiDien { get; set; }
        [Column]
        public string sMoTa { get; set; }
        [Column]
        public bool bDacBiet { get; set; }
        [Column]
        public bool bBanChay { get; set; }
        [Column]
        public bool bTrangChu { get; set; }
        [Column]
        public bool bQuanLy { get; set; }
        [Column]
        public int iSoLanXem { get; set; }

        public DanhMucHangHoa()
        {

        }
        public DanhMucHangHoa(SqlDataReader reader)
        {
            if (reader != null && !reader.IsClosed && reader.Read())
            {
                //if(!reader.IsDBNull(reader.GetOrdinal("iDonViTinh_ID"));
                if (DAHelper.HasColumn(reader, "iDanhMucHangHoa_ID")) iDanhMucHangHoa_ID = Convert.ToInt32(reader["iDanhMucHangHoa_ID"]);
                if (DAHelper.HasColumn(reader, "iLoaiHangHoa_ID")) iLoaiHangHoa_ID = Convert.ToInt32(reader["iLoaiHangHoa_ID"]);
                if (DAHelper.HasColumn(reader, "sMaHangHoa")) sMaHangHoa = reader["sMaHangHoa"].ToString();
                if (DAHelper.HasColumn(reader, "sTenHangHoa")) sTenHangHoa = reader["sTenHangHoa"].ToString();
                if (DAHelper.HasColumn(reader, "iDonViTinh_ID")) iDonViTinh_ID = Convert.ToInt32(reader["iDonViTinh_ID"]);
                if (DAHelper.HasColumn(reader, "dGiaBan")) dGiaBan = Convert.ToDecimal(reader["dGiaBan"]);
                if (DAHelper.HasColumn(reader, "dGiaKhuyenMai")) dGiaKhuyenMai = Convert.ToDecimal(reader["dGiaKhuyenMai"]);
                if (DAHelper.HasColumn(reader, "sHinhDaiDien")) sHinhDaiDien = reader["sHinhDaiDien"].ToString();
                if (DAHelper.HasColumn(reader, "sMoTa")) sMoTa = reader["sMoTa"].ToString();
                if (DAHelper.HasColumn(reader, "bDacBiet")) bDacBiet = Convert.ToBoolean(reader["bDacBiet"]);
                if (DAHelper.HasColumn(reader, "bBanChay")) bBanChay = Convert.ToBoolean(reader["bBanChay"]);
                if (DAHelper.HasColumn(reader, "bTrangChu")) bTrangChu = Convert.ToBoolean(reader["bTrangChu"]);
                if (DAHelper.HasColumn(reader, "bQuanLy")) bQuanLy = Convert.ToBoolean(reader["bQuanLy"]);
                if (DAHelper.HasColumn(reader, "iSoLanXem")) iSoLanXem = Convert.ToInt32(reader["iSoLanXem"]);
            }
            reader.Close();
            reader.Dispose();
        }
    }
}
